package com.lagou.service.lmpl;

import com.lagou.base.StatusCode;
import com.lagou.dao.CourseDao;
import com.lagou.dao.lmpl.CourseDaoImpl;
import com.lagou.pojo.Course;
import com.lagou.service.CourseService;
import com.lagou.untis.DateUtils;

import java.util.List;

public class CourseServiceImpl implements CourseService {
    @Override
    public List<Course>  findCourseList() {
        CourseDao courseDao = new CourseDaoImpl();
        List<Course> courseList = courseDao.findCourseList();
        return courseList;

    }




    @Override
    public List<Course> findCourseNameAndStatus(String course_name, String status) {
    CourseDao courseDao =  new CourseDaoImpl();
        List<Course> result = courseDao.findCourseNameAndStatus( course_name,status);
        return null;
    }


    @Override
    public String saveCourseSalesInfo(Course course) {

        //1.补全课程信息
        String dateFormart = DateUtils.getDateFormart();
        course.setCreate_time(dateFormart);
        course.setUpdate_time(dateFormart);
        course.setStatus(0);

        //2.调用Dao进行插入
        CourseDao courseDao=new CourseDaoImpl();
        int  i = courseDao.saveCourseSalesInfo(course);
        if(i>0){
            //保存成功
            String result = StatusCode.SUCCESS.toString();
            return result;

        }else{
            //保存失败
            String result = StatusCode.FAIL.toString();
            return result;
        }

    }
}

